<?php

/**
 * 维护个人信息
 * 
 * 制作:  叶风
 * Qq:    355007778
 * Email: ye.fn@163.com
 *
 */
namespace c\user;
\lang::load('user');
class my extends \control
{
    var $table = 'user';
    var $class = array('PU'=>'\c\auth\permission');
    var $dispLayout = 'user';
	
    
    function index_home()
    {
		$this->PU->login();
    	$res = $this->db->getOne($this->table, '*',  'id=' . \YF_f::$login_user_id);
		$gD = $this->db->getOne('user_grade', '*', 'id='. $res['grade_id']);
    	$this->loadTemplate('user/edit', array('data'=>$res, 'gD'=>$gD));
    }
    
    // 头像
    function index_epic()
    {
        $this->PU->login();
        $pic = $_POST['v'];
        $b = $this->db->save($this->table, array('pic'=>$pic), 'id='.  \YF_f::$login_user_id);
        ajax_json($b?TRUE:\lang::g('save fail'));
    }
    
    // 实时修改
    function index_ed()
    {
        $this->PU->login();
        $v = $_POST['v'];
        $n = $_POST['n'];
        
        $isA = array('sex', 'compellation');
        if(!in_array($n, $isA))
            ajax_json (\lang::g ('Over'));
        
        $b = $this->db->save($this->table, array($n=>$v), 'id='.  \YF_f::$login_user_id);
        ajax_json($b?TRUE:\lang::g('save fail'));
    }
}
